{extend name="base" /}
<!-- page specific plugin styles -->
{block name="inline-styles"}
{/block}
<!-- PAGE CONTENT BEGINS -->
{block name="content"}
<div class="page js_show">
    <div class="page__bd">
        <form class="weui-cells weui-cells_form weui-cells_checkbox" id="ajaxForm">

            <div class="weui-cell weui-cell_select weui-cell_select-after">
                <div class="weui-cell__hd"><label class="weui-label">支付方式</label></div>
                <div class="weui-cell__bd">
                    <select class="weui-select" name="paytype" onchange="selectType()">
                        <option value="1">银行卡</option>
                        <option value="2">支付宝</option>
                        <option value="3">微信支付</option>
                    </select>
                </div>
            </div>

            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" name="name" placeholder="请输入姓名">
                </div>
            </div>

            <div class="weui-cell" id="brankName">
                <div class="weui-cell__hd"><label class="weui-label">银行</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" name="addr" placeholder="请填写银行名称">
                </div>
            </div>

            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">账户</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" name="num" placeholder="请填写账户号">
                </div>
            </div>
            <label class="weui-cell weui-check__label" for="s11">
                <div class="weui-cell__hd">
                    <input type="checkbox" class="weui-check" name="ifdefault" id="s11" checked="checked" value="1">
                    <i class="weui-icon-checked"></i>
                </div>
                <div class="weui-cell__bd">
                    <p>设置默认</p>
                </div>
            </label>
        </form>

        <div class="weui-btn-area">
            <a class="weui-btn weui-btn_primary" href="javascript:;" id="showToast">保存</a>
        </div>
    
    </div>
    <div class="page__ft">
        <div class="weui-footer weui-footer_fixed-bottom">
            <p class="weui-footer__links">
                <a href="javascript:void(0);" class="weui-footer__link">米粒生活</a>
            </p>
            <p class="weui-footer__text">Copyright © 2008-2018 mlilife.com</p>
        </div>
    </div>
</div>
{/block}
<!-- PAGE CONTENT ENDS -->
<!-- inline scripts related to this page -->
{block name="related-scripts"}
<script type="text/javascript">
    $("#showToast").click(function(event) {
        /* Act on the event */
        var options={
            url:"/api/v1/payment/add",
            type:"POST",
            dataType:"json",
            success: function(json){

                if(json.returnCode==1){
                    $.toast("保存成功", function() {
                        window.location.href = "{:url('Index/bankcard')}";
                    });
                }else{
                    $.toptip(json.returnMsg, 'error');
                }
            }
        };
        $("#ajaxForm").ajaxSubmit(options)
    });

    // 选择支付方式
    function selectType(argument) {
        // body...
        var _thisVal = $("select[name=paytype]").val();
        if(_thisVal==1){
            $("#brankName").show();
        }else{
            $("#brankName").hide();
        }
    }
</script>
{/block}